#ifndef __TULING_LOG_H__
#define __TULING_LOG_H__

#include "us_ticker_api.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifndef TULING_LOG_LEVEL
#define TULING_LOG_LEVEL (3)
#endif
 
#if defined(TULING_LOG_LEVEL)
#define TULING_LOG(_level, ...)     \
    printf("[%s][%lu] %s(%d): ", _level ,us_ticker_read(), __FILE__, __LINE__), \
    printf(__VA_ARGS__), \
    printf("\n");
#endif

#if defined(TULING_LOG_LEVEL) && (TULING_LOG_LEVEL >= 5)
#define TULING_LOGV(...)          TULING_LOG("V", __VA_ARGS__)
#else
#define TULING_LOGV(...)
#endif

#if defined(TULING_LOG_LEVEL) && (TULING_LOG_LEVEL >= 4)
#define TULING_LOGD(...)          TULING_LOG("D", __VA_ARGS__)
#else
#define TULING_LOGD(...)
#endif

#if defined(TULING_LOG_LEVEL) && (TULING_LOG_LEVEL >= 3)
#define TULING_LOGI(...)          TULING_LOG("I", __VA_ARGS__)
#else
#define TULING_LOGI(...)
#endif

#if defined(TULING_LOG_LEVEL) && (TULING_LOG_LEVEL >= 2)
#define TULING_LOGW(...)          TULING_LOG("W", __VA_ARGS__)
#else
#define TULING_LOGW(...)
#endif

#if defined(TULING_LOG_LEVEL) && (TULING_LOG_LEVEL >= 1)
#define TULING_LOGE(...)          TULING_LOG("E", __VA_ARGS__)
#else
#define TULING_LOGE(...)
#endif


#ifdef __cplusplus
}
#endif
#endif
